package edu.hrbu.spring.service.impl;

import edu.hrbu.spring.dao.ActDao;
import edu.hrbu.spring.pojo.Act;
import edu.hrbu.spring.service.IsolationService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;

/**
 * @author 徐登宇
 */
@Service
public class IsolationServiceImpl2 implements IsolationService {

    @Resource(name = "actDaoImpl")
    private ActDao actDao;

    @Override
    public boolean save(Act act) {
        return false;
    }

    @Override
//    @Transactional(isolation = Isolation.READ_UNCOMMITTED)
    // 该方法的隔离级别是读未提交（可以读到未提交的数据）
    @Transactional(isolation=Isolation.READ_COMMITTED)
    // 该方法的隔离级别是读已提交（只能读取到提交的数据）
    public Integer selectById(int id) {
        return actDao.selectByNo(id);
    }
}
